package com.zbkj.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.common.model.UserAiInfo;
import com.zbkj.service.dao.UserAiInfoDao;
import com.zbkj.service.service.UserAiInfoService;
import com.zbkj.service.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author keNan
 * @description UserAiInfoServiceImpl 接口实现
 * @date 2025-05-12
 */
@Service
public class UserAiInfoServiceImpl extends ServiceImpl<UserAiInfoDao, UserAiInfo> implements UserAiInfoService {

    @Autowired
    private UserService userService;


    /**
     * 根据用户id查询用户ai信息
     *
     * @param id
     * @return
     */
    @Override
    public UserAiInfo getInfo(Integer id) {
        LambdaQueryWrapper<UserAiInfo> lqw = new LambdaQueryWrapper<>();
        lqw.select(UserAiInfo::getAge, UserAiInfo::getBust, UserAiInfo::getHeight, UserAiInfo::getId, UserAiInfo::getSex,
                UserAiInfo::getUserAiFace, UserAiInfo::getWeight, UserAiInfo::getAiBackgroundId);
        lqw.eq(UserAiInfo::getId, id);
        return getOne(lqw);
    }


    /**
     * 查询用户人脸url
     *
     * @return
     */
    @Override
    public String selectAiFace() {
        Integer userId = userService.getUserId();
        UserAiInfo userAiInfo = getById(userId);
        return userAiInfo != null ? userAiInfo.getUserAiFace() : "";
    }

}

